from django.db import models

# Create your models here.

# code from: https://stackoverflow.com/questions/5870537/whats-the-difference-between-django-onetoonefield-and-foreignkey

class Car(models.Model):
    name = models.CharField(max_length=25)

    def __str__(self):
        return self.name

class Engine(models.Model):
    name = models.CharField(max_length=25)
    car = models.ForeignKey(Car, on_delete=models.CASCADE)
    def __str__(self):
        return self.name

class Car2(models.Model):
    name = models.CharField(max_length=25)

    def __str__(self):
        return self.name

class Engine2(models.Model):
    name = models.CharField(max_length=25)
    car2 = models.ForeignKey(Car2, unique=True, on_delete=models.CASCADE)

    def __str__(self):
        return self.name


class Car3(models.Model):
    name = models.CharField(max_length=25)

    def __str__(self):
        return self.name

class Engine3(models.Model):
    name = models.CharField(max_length=25)
    car3 = models.OneToOneField(Car3, on_delete=models.CASCADE)

    def __str__(self):
        return self.name
